﻿using Max.PH4_2101A.ShoppingAdmin.FuXi.API.SecondWeekExam.Domain;
using Max.PH4_2101A.ShoppingAdmin.FuXi.API.SecondWeekExam.IService;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Max.PH4_2101A.ShoppingAdmin.FuXi.API.Controllers.Second
{
    /// <summary>
    /// 
    /// </summary>
    [Route("second/prodct")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        IProductService _prodctService;
        IBrandService _brandService;
        NLog.Logger _log;

        public ProductController(IProductService prodctService, IBrandService brandService)
        {
            _prodctService = prodctService;
            _brandService = brandService;
            _log = NLog.LogManager.GetCurrentClassLogger();
        }

        /// <summary>
        /// 绑定品牌
        /// </summary>
        /// <returns></returns>
        [HttpGet("brand")]
        public IActionResult BindBrand()
        {
            try
            {
                var list = _brandService.Query();
                return Ok(new { code = 200, message = "操作成功", data = list });
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
                return Ok(new { code = 500, message = $"操作失败，原因：{ex.Message}"});
            }
        }

        /// <summary>
        /// 产品列表
        /// </summary>
        /// <param name="name"></param>
        /// <param name="brandId"></param>
        /// <param name="date1"></param>
        /// <param name="date2"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Query(string? name = "", string? brandId = "-1", string? date1 = "", string? date2 = "")
        {

            //参数验证
            name = name ?? "";


            return Ok();
        }

        /// <summary>
        /// 产品添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Insert(ProductModel model)
        {
            return Ok();
        }

        /// <summary>
        /// 图片上传
        /// </summary>
        /// <returns></returns>
        [HttpPost("upload")]
        public IActionResult Upload(IFormFile file)
        {
            return Ok();
        }
    }
}
